package com.gk.panda.apis.patrol.controller.client;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gk.panda.apis.patrol.servicr.ReportService;
import com.gk.panda.commons.result.Result;
import com.gk.panda.pojo.patrol.dto.DetailListDTO;

import com.gk.panda.pojo.patrol.dto.UpdateDetailDTO;
import com.gk.panda.pojo.patrol.request.SaveReportRequest;
import com.gk.panda.pojo.patrol.request.UpdateReportRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

/**
 * @Author：xxz
 * @Create: 2022/11/1 16:24
 */
@RestController
@RequestMapping("/report/client")
@Api(tags = "巡护事件App相关接口")
public class ReportClientController {

    @Resource
    private ReportService reportService;

    @PostMapping("/save")
    @ApiOperation("新增")
    public Result<?> saveReport(@RequestBody @Validated SaveReportRequest request) {
        return Result.ok(reportService.saveReport(request));
    }

    @GetMapping("/detailList")
    @ApiOperation("查询详情")
    public Result<DetailListDTO> detail(@NotNull @RequestParam Long id) {
        return Result.ok(reportService.detailList(id));
    }

    @DeleteMapping("/delete")
    @ApiOperation("删除事件")
    public Result<?> delete(@NotNull @RequestParam Long id) {
        return reportService.remove(id);
    }

    @GetMapping("/updateDetail")
    @ApiOperation("查询事件修改详情")
    public Result<UpdateDetailDTO> updateDetail(@RequestParam("id") Long id) {
        return Result.ok(reportService.updateDetail(id));
    }

    @PutMapping("/update")
    @ApiOperation("修改事件")
    public Result<?> update(@Validated @RequestBody UpdateReportRequest request) {
        return reportService.update(request);
    }
}
